<?php

namespace app\home\controller;

use app\BaseController;
use app\home\model\News as ModelNews;
use app\home\model\Seo;
use think\facade\View;
use app\api\model\Usage;


class News extends BaseController{
    public function index(){
        $news_hot = ModelNews::getByOrder('hot_order_desc', 10);
        $news_hot1 = [];
        $news_hot2 = [];
        foreach ($news_hot as $key => $n_h) {
            if($key < 2){
                array_push($news_hot1, $n_h);
            }else{
                array_push($news_hot2, $n_h);
            }
        }
        View::assign('news_hot1', $news_hot1);
        View::assign('news_hot2', $news_hot2);
        View::assign('news', ModelNews::getByOrder('date_desc', 30));
        View::assign('kw', Seo::getKeywords());
        View::assign('desc', Seo::getDesc());
        $usage = new Usage;
        $usage->save([
            'access_page'=>'Other',
            'access_time'=>date('Y-m-d', time()),
            'access_ip'=>$_SERVER["REMOTE_ADDR"]
        ]);
        return View::fetch();
    }
    
}